<template>
	<view class="detail">
		<view class="shop_info">
			<view class="shop_info_top">
				<image class="s_img" :src="info.imgSrc" mode=""></image>
				<view class="shop_info_top_right">
					<view class="name_box">
						<view class="name">{{info.title}}</view>
						<view class="jilu">{{info.jilu}}</view>
					</view>
					<view class="renqi">
						<text>{{info.province}}{{info.city}}{{info.area}}</text>
						<text class="text">人气:{{info.saleNum}}</text>
					</view>
				</view>
			</view>
			<view class="banner_box">
				<swiper class="banner_swiper" :indicator-dots="false" :autoplay="true" :interval="5000" :duration="300" circular="true" indicator-color="#fff" indicator-active-color="#6686f5">
					<swiper-item v-for="item in imgs" >
						<view class="swiper-item"><image class="img" lazy-load :src="item" mode="aspectFill"></image></view>
					</swiper-item>
				</swiper>
			</view>
			<view class="address_box">
				<view class="address_box_left" @click="goaddress()">
					<view class="address" >
						<image class="a_img" src="../../static/images/location.png" mode=""></image>
						<view class="add">{{info.address}}</view>
					</view>
					<view class="address">
						<view class="add time">营业时间：{{info.businessTime}}</view>
					</view>
				</view>
				<image @click="makep()" class="p_img" src="../../static/images/phone.png" mode=""></image>
			</view>
			<view class="shop_remark">
				
				<view class="html" v-html="html"></view>
			</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				html:`<p>店铺描述店铺描述店铺描述店铺描述店铺描述店铺描述店铺描述店铺描述店铺描述店铺描述店铺描述店铺描述店铺描述店铺描述店铺描述店铺描述店铺描述店铺描述店铺描述店铺描述店铺描述店铺描述店铺描述店</p>`,
				longitude:0,
				latitude:0,
				info:[],
				id:0,
				imgs:[]
			}
		},
		onLoad(options) {
			this.userinfo=uni.getStorageSync('user');
			this.id=options.id;
			this.longitude=uni.getStorageSync('userlon');
			this.latitude=uni.getStorageSync('userlat');
			this.getinfo();
		},
		methods: {
			goaddress(){
				console.log(1);
				var that=this;
				uni.getLocation({
					type: 'gcj02', //返回可以用于uni.openLocation的经纬度
					success: function (res) {
						const lat = parseFloat(that.latitude);
						const lon = parseFloat(that.longitude);
						console.log(lat,lon);
						uni.openLocation({
							latitude: lat,
							longitude: lon,
							success: function () {
								this.getinfo();
							}
						});
					}
				});

			},
			makep(){
				var phone=this.info.contactPhone;
				uni.makePhoneCall({
					phoneNumber: phone //仅为示例
				});
			},
			getinfo(){
				var that=this;
				this.$http.get('shop/shopDetail',{
					id:that.id,
					userlon:that.longitude,
					userlat:that.latitude
				}).then(function (response) {
					that.info=response.data;
					that.html=response.data.detail;
					that.imgs=response.data.images;
					that.latitude=response.data.lat;
					that.longitude=response.data.lon;
				}).catch(function (error) {
					console.log(error);
				});
				
			}
		}
	}
</script>

<style scoped lang="scss">
	.detail{
		width: 100%;
		.btn{
			position: fixed;
			bottom: 50rpx;
			left: 50%;
			transform: translateX(-50%);
			width: 690rpx;
			background: #6686f5;
			color: #fff;
			font-size: 32rpx;
			font-weight: bold;
			border-radius: 48rpx;
			height: 96rpx;
			line-height: 96rpx;
			text-align: center;
		}
		.address_box{
			padding: 30rpx;
			border-top: 1px solid #f5f5f5;
			border-bottom: 1px solid #f5f5f5;
			display: flex;
			align-items: center;
			justify-content: space-between;
			.p_img{
				width: 40rpx;
				height: 40rpx;
			}
			.address_box_left{
				position: relative;
				padding-right: 30rpx;
				&:after{
					content: '';
					position: absolute;
					top: 0;
					right: 0;
					width: 1px;
					height: 100%;
					background: #f5f5f5;
				}
				.address{
					display: flex;
					align-items: center;
					.add{
						margin-left: 10rpx;
						width: 530rpx;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
						font-size: 28rpx;
						color: #333;
					}
					.time{
						margin-left: 42rpx;
						padding-top: 10rpx;
					}
					.a_img{
						width: 32rpx;
						height: 32rpx;
					}
				}
			}
		}
		.shop_info{
			padding: 0 30rpx;
			.shop_remark{
				padding: 30rpx 0;
				color: #333;
				.type{
					width: 130rpx;
					font-size: 28rpx;
				}
				.html{
					flex: 1;
					font-size: 28rpx;
				}
			}
			.banner_box{
				margin-top: 30rpx;
				width: 100%;
				height: 272rpx;
				.banner_swiper{
					width: 100%;
					height:272rpx;
					.swiper-item{
						display: flex;
						width: 100%;
						height: 100%;
						justify-content: center;
						.img{
							display: block;
							width: 100%;
							height: 272rpx;
						}
					}
				}
			}
			.shop_info_top{
				display: flex;
				align-items: center;
				.shop_info_top_right{
					flex: 1;
					margin-left: 20rpx;
					.renqi{
						padding-top: 14rpx;
						color: #666666;
						font-size: 24rpx;
						.text{
							margin-left: 10rpx;
							padding: 0 10rpx;
							background: #eef2ff;
							border-radius: 10rpx;
							color: #6686f5;
							font-size: 22rpx;
						}
					}
					.name_box{
						display: flex;
						align-items: center;
						justify-content: space-between;
						.name{
							font-size: 32rpx;
							font-weight: bold;
							color: #333;
						}
						.jilu{
							font-size: 24rpx;
							color: #666;
						}
					}
				}
				.s_img{
					width: 100rpx;
					height: 100rpx;
				}
			}
		}
	}
</style>
